package com.wankuma.hcm.midlet;

import METwit;

import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;

public class ListDialog extends List {

	private int dialogResult = DialogResult.CANCEL;

	public int getDialogResult() {
		return dialogResult;
	}

	protected void setDialogResult(int dr) {
		this.dialogResult = dr;
	}

	public ListDialog(String title, int type) {
		super(title, type);
	}

	public int showDialog() {
		ShowDialogThread t = new ShowDialogThread(this);
		t.start();

		return t.dialog.dialogResult;
	}

	private class ShowDialogThread extends Thread {
		
		private ListDialog dialog;
		
		public ShowDialogThread(ListDialog d){
			this.dialog = d;
		}
		
		public void run() {
			METwit.getDisplay().setCurrent(dialog);
			
			synchronized (dialog) {
				try{
					dialog.wait();
				}catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
	}

}